package com.ee.chat.admin.controller.systemmanage;

import com.ee.chat.admin.service.ISysConfigService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author Shane
 * @Date 2020/3/15 22:54
 */
@RestController
@RequestMapping("sysConfig")
public class SysConfigController {
    private Logger log = LoggerFactory.getLogger(this.getClass());

    @Resource
    ISysConfigService sysConfigService;

    @RequestMapping("list")
    public Result list(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit){
        try {
            return sysConfigService.list(request, page, limit);
        } catch (Exception e){
            log.error("【获取系统配置参数列表错误】", e);
        }
        return Result.returnFailure();
    }

    @RequestMapping("edit")
    public Result edit(HttpServletRequest request, @RequestParam Integer id, @RequestParam String value){
        try {
            return sysConfigService.edit(request, id, value);
        } catch (Exception e){
            log.error("【更新系统配置参数错误】", e);
        }
        return Result.returnFailure();
    }
}
